/**
 * Created by WUJO5 on 2/12/2018.
 */

var express = require('express');
var urlmappingCtrl = require('../controller/urlmappingController');
var tempUrlCtrl = require('../controller/tempUrlController');
var router = express.Router();

router.post('/add',function(req,res){
    urlmappingCtrl.insertUrl(req.body.params,function(data){
        res.send(data);
    },function (err) {
        res.send(err)
    })
});
router.put('/edit',function(req,res){
    urlmappingCtrl.updateUrl(req.body.params,function (data) {
        res.send(data);
    },function (err) {
        res.send(err);
    })
})

router.post('/singleRemove',function(req,res){
    urlmappingCtrl.removeUrl(req.body.params,function(data){
        res.send(data);
    },function(err){
        res.send(err);
    })
});

router.get('/urlPageList/:page/:pageSize',function(req,res){
    urlmappingCtrl.getUrlPageList(req.params,function(data){
        res.send(data);
    },function (err) {
        res.send(err);
    })
});

router.get('/urlList',function(req,res){
    urlmappingCtrl.getUrlList(req.params,function(data){
        res.send(data);
    },function (err) {
        res.send(err);
    })
});

router.get('/FilterUrlList/:keywords/:page/:pageSize',function(req,res){
    urlmappingCtrl.getUrlPageList(req.params,function(data){
        res.send(data);
    },function (err) {
        res.send(err);
    })
});

router.post('/url',function (req,res) {
    urlmappingCtrl.checkUrlUnique(req.body.params,function (data) {
        res.send(data);
    },function (err) {
        res.send(err)
    })
});

router.delete('/batchremove/:urlIds',urlmappingCtrl.batchRemoveUrl);

router.post('/getByUrl',urlmappingCtrl.getByURl);
router.post('/getByParamsMethod', urlmappingCtrl.getByParamsMethod);
router.post('/parseSoapRequestBody', urlmappingCtrl.parseSoapRequestbody);
router.get('/getAllRepleacedUrlList', urlmappingCtrl.getAllRepleacedUrlList );
router.get('/getById/:id', urlmappingCtrl.getById );
router.get('/clearTempUrl', tempUrlCtrl.clearTempUrl);
router.post('/insertTempUrl', tempUrlCtrl.insertUrl);
router.post('/findResponseDataByUrl', tempUrlCtrl.findResponseDataByUrl);
router.post('/getAllUrlsByBizKey', tempUrlCtrl.getAllUrlsByBizKey);
router.post('/batchInsertTempUrls', tempUrlCtrl.batchInsertTempUrls);

module.exports = router;

